<?php if(!defined('HDWIKI_ROOT')) exit('Access Denied');?>
<?php include $this->gettpl('header');?>
<script type="text/javascript">
function compare(){
	var docs;
	try{
		document.documentElement.scrollTop=0;
		if($("input[name='eid[]']").length==null){
			alert("页面错误,请刷新页面");
		}else{
			switch($("input:checked").length){
				case 0:
				alert("请选择版本");
				break;
				case 1:
				alert("需要有两个版本比较");
				break;
				case 2:
				$("form[name='editionform']").attr('target',"_blank");
				$("form[name='editionform']").attr('action',"index.php?edition-compare");
				$("form[name='editionform']").submit();
				break;
				default:
				alert("最多只能有两个版本比较");
				break;
			}
		}
	}catch(e){
		alert("请选择版本");
	}
}
function removedoc(){
	if($("input[name='eid[]']").length==null){
		alert("页面错误,请刷新页面");
	}else{
		if($("input:checked").length<1){
			alert("请选择要删除的版本");
			return false;
		}
	}
	if(confirm("删除版本后不可恢复,确定删除吗")==false){
		return false;
	}else{
		$("form[name='editionform']").attr('target',"_self");
		$("form[name='editionform']").attr('action',"index.php?edition-remove");
		$("form[name='editionform']").submit();
	}
}

function excellence(){
	if($("input[name='eid[]']").length==null){
		alert("页面错误,请刷新页面");
	}else{
		if($("input:checked").length<1){
			alert("请选择要设置为优秀的版本");
			return false;
		}
	}
	if(confirm("确定要设置这些版本为优秀的版本吗?")==false){
		return false;
	}else{
		$("form[name='editionform']").attr('target',"_self");
		$("form[name='editionform']").attr('action',"index.php?edition-excellent");
		$("form[name='editionform']").submit();
	}
}

function copy(){
	if($("input[name='eid[]']").length==null){
		alert("页面错误,请刷新页面");
	}else{
		if($("input:checked").length!=1){
			alert("请只选择一个版本复制");
			return false;
		}
	}
	if(confirm("确定将此版本复制为最新的版本吗?")==false){
		return false;
	}else{
		$("form[name='editionform']").attr('target',"_self");
		$("form[name='editionform']").attr('action',"index.php?edition-copy");
		$("form[name='editionform']").submit();
	}	
}
</script>
<div class="hd_map">
	<a href="<?php echo WIKI_URL?>" target="_blank"><?php echo $setting['site_name']?></a> &gt;&gt; <a href="index.php?doc-view-<?php echo $doc['did']?>"><?php echo $doc['title']?></a> &gt;&gt; 历史版本列表
	</div>

<div class="version">
	<h1 class="title_thema bor_b-ccc"><strong class="l"><?php echo $doc['title']?></strong><a href="index.php?doc-view-<?php echo $doc['did']?>" target="_self" class="r">返回词条</a></h1>
	<span class="bold m-t10 version_title">历史版本</span>
	<form method="post" name="editionform">
	<table cellspacing="0" cellpadding="0" class="table w-950 l">
		<thead>
		<tr>
			<td style="width: 150px;">历史版本</td>
			<td style="width: 100px;">创建时间</td>
			<td style="width: 140px;">版本创建者</td>
			<td style="width: 70px;">版本变动</td>
			<td style="width: 70px;">优秀</td>
			<td style="width: 70px;">金币</td>
			<td style="width: 220px;">修改原因</td>

		</tr>
		</thead>
		<tbody>
		<?php foreach((array)$editionlist as $key=>$edition) {?>
		<tr>
			<td><input name="eid[]" value="<?php echo $edition['eid']?>" type="checkbox" /><input name="editions_<?php echo $edition['eid']?>" value="<?php echo count($editionlist)-$key?>" type="hidden" />
			<a href="index.php?edition-view-<?php echo $edition['eid']?>-<?php echo count($editionlist)-$key?>">历史版本<?php echo count($editionlist)-$key?></a></></td>
			<td class="gray"><?php echo $edition['time']?></td>
			<td><a href="index.php?user-space-<?php echo $edition['authorid']?>" ><?php echo $edition['author']?></a>
			<span title="星星数 <?php echo $edition['stars']?>"><?php for($i=0; $i<$edition['editorstar'][3]; $i++) {?><img src="style/default/star_level3.gif"/><?php } ?><?php for($i=0; $i<$edition['editorstar'][2]; $i++) {?><img src="style/default/star_level2.gif"/><?php } ?><?php for($i=0; $i<$edition['editorstar'][1]; $i++) {?><img src="style/default/star_level1.gif"/><?php } ?></span>
			</td>
			<td><?php if($edition['big']==1) { ?>大<?php } else { ?>小<?php } ?></td>
			<td><?php if($edition['excellent']==1) { ?><img src="style/default/excellent.gif"><?php } ?></td>
			<td class="orange" ><?php if($edition['coins']) { ?><img src="style/default/jb.gif"> <?php if($edition['coins']>0) { ?>+<?php } ?><?php echo $edition['coins']?><?php } ?></td>
			<td><?php echo $edition['reason']?></td>
		</tr>
		<?php }?>
		</tbody>
		<tfoot>
		<tr><td colspan="6"><input type="hidden" value="<?php echo $doc['did']?>" name="did"/></td></tr>
		</tfoot>
	</table>

<div class="operation_btn">	
	<input type="button" onclick="compare();" value="版本对比" class="btn_inp"/>
	<?php if($checkable['remove']) { ?><input type="button" onclick="removedoc();" value="删除" class="btn_inp"/><?php } ?>	
	<?php if($checkable['excellent']) { ?><input type="button" onclick="excellence();" value="优秀" class="btn_inp"/><?php } ?>
	<?php if($checkable['copy']) { ?><input type="button" onclick="copy();" value="复制" class="btn_inp"/><?php } ?>
</div>
</form>
</div>



<div class="c-b"></div>
<?php include $this->gettpl('footer');?>

